<template>
    <view :class="[item.istop ? 'bg-light' : 'bg-white','container']" hover-class="bg-light">
        <view class="chatBox flex align-stretch "  @longpress="long" @click="onClick">
            <view class="flex align-center justify-center position-relative" style="width: 145rpx;">
				<u-avatar  size="120rpx" :src="getBaseUrl(item.avatar) "></u-avatar>
                <free-badge badgeClass="position-absolute" badgeStyle="top:10rpx;right:10rpx" v-if="item.noreadnum"
                    :value="item.noreadnum"></free-badge>
            </view>
           <view class="chatRight  py-3 pr-3 border-light-secondary " >
                <view class="first mb-1 text-light-muted">
                    {{item.update_time|formatTime}}
                </view>
                <view class="two font text-ellipsis text-light-muted">{{item.data}}</view>
            </view>
           
           

        </view>
    </view>
</template>

<script>
    import freeBase from "@/common/mixin/free-base.js"

    import freeBadge from "@/components/chat/free-badge.vue"
    import {
        visitApi
    } from '@/api/patientRegistration/registrationList.js'

    import {
        mapState
    } from 'vuex'

    export default {
        mixins: [freeBase],
        data(){
            return{
                patientHospital:{},
                patientList:[],
            }
        },
        components: {
            freeBadge
        },
        props: {
            item: Object,
            index: Number
        },
        computed: {
            ...mapState({
                chat: state => state.user.chat
            })
        },
        mounted() {
            
            // this.getAllPatientList()
        },
        methods: {
           
            onClick() {
                this.$store.commit('SET_CHATOBJ',this.item)
                console.log('this.item===',this.item)
                this.$tab.navigateTo(`/subPackages/message/consoluting` )
                // this.$tab.navigateTo(`/subPackages/message/consoluting?wssUuid=${item.id}&userId=${item.extend.userId}&isPatient=${item.extend.isPatient} ` )
                // uni.navigateTo({
                //     url: '/pages/chat/chat/chat?params=' + encodeURIComponent(JSON.stringify({
                //         id: this.item.id,
                //         name: this.item.name,
                //         avatar: this.item.avatar,
                //         chat_type: this.item.chat_type,
                //     })),
                    
                // });
                this.chat.readChatItem(this.item.id, this.item.chat_type)
            },
            long(e) {
                let x = 0
                let y = 0
                // #ifdef APP-PLUS-NVUE
                if (Array.isArray(e.changedTouches) && e.changedTouches.length > 0) {
                    x = e.changedTouches[0].screenX
                    y = e.changedTouches[0].screenY
                }
                // #endif
                // #ifdef H5
                x = e.changedTouches[0].pageX
                y = e.changedTouches[0].pageY
                // #endif
                // #ifdef MP
                x = e.detail.x
                y = e.detail.y
                // #endif
                this.$emit('long', {
                    x,
                    y,
                    index: this.index
                })
            },
            // 获取所有顾客列表
            // getAllPatientList() {
            //     this.patientHospital = uni.getStorageSync('patientHospital')
            //     let params = {
            //         pageNum: 1,
            //         pageSize: 99999,
            //         hospitalId: this.patientHospital.hospitalId,
                    
            //     }
            //     visitApi.listVisitTip(params).then((response) => {
            //         if(response.code==200){
            //             this.patientList=response.rows
            //             console.log(' this.patientList---', this.patientList)
            //         }
            
            //     });
            // },
            
        }
    }
</script>

<style scoped lang="scss">
    .container{
        .chatBox{
            padding: 20rpx 10rpx;
            box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.3);
            // background: #fff;
            border-radius: 10px;
            margin: 20rpx 0;
			.chatRight {
			        width: 80%;
			        .first {
			          text-align: right;
			        }
			      }
        }
        
    }
    
</style>
